<template>
  <div class="card">
    <div class="card-img-mark"></div>
    <div class="flip-over prev" v-if="isPrev">
      <a :href="flipOverUrl">上一篇</a>
    </div>
    <div class="flip-over next" v-if="isNext">
      <a :href="flipOverUrl">下一篇</a>
    </div>
    <img class="card-img " :src="require('./8.jpg')" alt="Card image" />
    <div class="card-body">
      <h4 class="card-title">{{ name }}</h4>
      <p class="card-text">{{ describe }}...</p>
      <div class="card-time">
        <Icon type="ios-time-outline" />
        <span>{{ create_time | formatTime("yyyy-MM-dd") }}</span>
      </div>
      <div class="card-sort">
        <Icon type="ios-bookmark" />
        <span>分类</span>
      </div>
      <div class="card-label">
        <button class="card-label-button" v-for="tag in tags" :key="tag.tag_id">
          <a href="#">{{ tag.tag_name }}</a>
        </button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "index",
  props: {
    cover: {
      type: String,
      default: "@/assets/img/8.jpg"
    },
    name: {
      type: String,
      default: "文章名称文章名称文章名称文章名称"
    },
    describe: {
      type: String,
      default: "介文章简介文章简介文章简介文章简介文章简介"
    },
    create_time: {
      type: Date,
      default: () => new Date()
    },
    tags: {
      type: Array,
      default: () => [
        {
          tag_name: "标签",
          tag_id: 1
        }
      ]
    },
    category: {
      type: Object,
      default: () => ({ cate_name: "分类名", cate_id: 1 })
    },
    isNext: {
      type: Boolean,
      default: false
    },
    isPrev: {
      type: Boolean,
      default: true
    },
    flipOverUrl: {
      type: String
    }
  }
};
</script>

<style lang="less" scoped>
.card {
  cursor: pointer;
  margin: 300px auto;
  transition: all 0.35s ease-in-out;
  width: 335px;
  box-sizing: border-box;
  float: left;
  border-style: none;
  box-shadow: 0 15px 35px rgba(50, 50, 93, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07) !important;
  border-radius: 8px;
  overflow: hidden;
  background-color: #ffffff;
  position: relative;
  &:hover {
    animation: card-animation 0.85s;
  }
  .flip-over {
    position: absolute;
    width: 60px;
    line-height: 20px;
    background-color: white;
    font-size: 17px;
    font-weight: 300;
    color: #66afe9;
    text-align: center;
    top: 20px;
    border-radius: 3px;
    &.next {
      right: 0;
    }
    &.prev {
      left: 0;
    }
  }

  .card-img-mark {
    position: absolute;
    height: 220px;
    width: 450px;
    background-color: rgba(0, 0, 0, 0.3);
  }
  .card-img {
    height: 220px;
    width: 450px;
    border-radius: 8px 8px 0 0;
    object-fit: cover;
  }
  .card-body {
    width: 100%;
    .card-title {
      position: absolute;
      bottom: 180px;
      font-size: 24px;
      color: #ffffff;
      padding: 0 24px;
      font-weight: 300;
    }
    .card-text {
      font-size: 12px;
      margin: 10px;
    }
    .card-time {
      font-size: 13px;
      margin-left: 10px;
    }
    .card-sort {
      font-size: 13px;
      float: right;
      padding-right: 25px;
      margin-top: -17px;
    }
    .card-label {
      margin-top: 10px;
      background-color: inherit;
      border-top: 1px solid rgba(160, 160, 160, 0.2);
      position: relative;
      line-height: 40px;
      padding-left: 30px;
      .card-label-button {
        background: -webkit-gradient(
          linear,
          0 100%,
          100% 100%,
          from(#6783af),
          to(#dae6e3)
        ); /** Chrome Safari **/
        background: -moz-linear-gradient(
          left,
          #6783af,
          #dae6e3
        ); /** FireFox **/
        background: -o-linear-gradient(left, #6783af, #dae6e3); /** Opear **/
        background: -ms-linear-gradient(
          #6783af 0%,
          #dae6e3 100%
        ); /** IE9 IE10 **/
        filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1,startColorstr='#6783AF',endColorstr='#DAE6E3'); /** IE7 **/
        -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#6783AF',endColorstr='#DAE6E3',gradientType=1); /** IE8 **/
        border-radius: 10px;
        text-decoration: none;
        border: none;
        font-size: 0.8rem;
        margin: 2px;
        font-weight: 400;
        height: 22px;
        line-height: 22px;
        color: #fff;
      }
    }
  }
}
@keyframes card-animation {
  50% {
    transform: scale(1.1, 1.1);
  }
  100% {
    transform: scale(1, 1);
  }
}
</style>
